<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Course/index')}">课程列表</a></li>
        <li><a href="{:url('Course/add')}">添加课程</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="get" action="{:url('Course/index')}">
        关键字:
        <input type="text" class="form-control" name="keyword" style="width: 220px;" value="{:input('request.keyword/s','')}" placeholder="课程名称/分类名称">
        状态:
        <select class="form-control" name="status">
            <option value="">请选择状态</option>
             <option value="1" <if condition="$status eq 1">selected</if>>拼团中</option>
             <option value="2" <if condition="$status eq 2">selected</if>>已下架</option>
             <option value="3" <if condition="$status eq 3">selected</if>>已成团</option>
        </select>
        推荐:
        <select class="form-control" name="is_hot">
            <option value="">请选择状态</option>
            <option value="1" <if condition="$is_hot eq 1">selected</if>>是</option>
            <option value="2" <if condition="$is_hot eq 2">selected</if>>否</option>
        </select>
        时间:
        <input class="form-control js-bootstrap-datetime" type="text" name="start_time"
               value="{:input('request.start_time/s','')}" placeholder="请输入开始时间">
        -
        <input class="form-control js-bootstrap-datetime" type="text" name="end_time"
               value="{:input('request.end_time/s','')}" placeholder="请输入结束时间">
        <input type="submit" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="{:url('Course/index')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form margin-top-20" action="{:url('Course/listOrder')}">
        <div class="table-actions">
            <button class="btn btn-xs btn-success js-ajax-submit" type="submit">{:lang('SORT')}</button>
            <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                    data-action="{:url('Course/toggle',array('is_hot'=>1))}" data-subcheck="true">推荐
            </button>
            <button class="btn btn-sm btn-danger js-ajax-submit" type="submit"
                    data-action="{:url('Course/toggle',array('is_hot'=>2))}" data-subcheck="true">取消推荐
            </button>
            <button class="btn btn-primary btn-sm js-ajax-submit" type="submit"
                    data-action="{:url('Course/toggle',array('status'=>1))}" data-subcheck="true">发布
            </button>
            <button class="btn btn-sm btn-danger js-ajax-submit" type="submit"
                    data-action="{:url('Course/toggle',array('status'=>2))}" data-subcheck="true">下架
            </button>
            <button class="btn btn-sm btn-danger js-ajax-submit" type="submit"
                    data-action="{:url('Course/toggle',array('delete'=>1))}" data-subcheck="true">删除
            </button>
        </div>
        <php>
            $status=array("1"=>'拼团中',"2"=>'下架','3'=>'已成团');
            $is_hot=array('1'=>'是','2'=>'否');
        </php>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16"><label><input type="checkbox" class="js-check-all" data-direction="x"
                                             data-checklist="js-check-x"></label></th>
                <th width="50">{:lang('SORT')}</th>
                <th width="50">ID</th>
                <th>课程名称</th>
                <th>分类名称</th>
                <th>主图</th>
                <th>价格</th>
                <th>团购价</th>
                <th>已参团人数</th>
                <th>团购总人数</th>
                <th>库存数</th>
                <th>分佣比例</th>
                <th>创建时间</th>
                <th>结束时间</th>
                <th>是否推荐</th>
                <th width="50">{:lang('STATUS')}</th>
                <th width="120">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="list" item="vo">
                <tr>
                    <td><input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.course_id}"></td>
                    <td>
                        <input name="list_orders[{$vo.course_id}]" class="input-order" type="text" value="{$vo.list_order}">
                    </td>
                    <td>{$vo.course_id}</td>
                    <td>{$vo.course_name}</td>
                    <td>{$vo.cate_name}</td>
                    <td>
                        <if condition="!empty($vo['image'])">
                            <a href="javascript:imagePreviewDialog('{:cmf_get_image_preview_url($vo.image)}');">
                                <i class="fa fa-photo fa-fw"></i>
                            </a>

                        </if>
                    </td>
                    <td>{$vo.price}</td>
                    <td>{$vo.assemble_price}</td>
                    <td>{$vo.now_num}</td>
                    <td>{$vo.total_num}</td>
                    <td>{$vo.sku}</td>
                    <td>{$vo.proportion}</td>
                    <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                    <td>{:date('Y-m-d H:i:s',$vo['end_time'])}</td>
                    <td>
                        <if condition="$vo.is_hot eq 1">
                            <span class="label label-success">
                                {$is_hot[$vo['is_hot']]}
                            </span>
                            <else/>
                            <span class="label btn-danger">
                                {$is_hot[$vo['is_hot']]}
                            </span>
                        </if>
                    </td>
                    <td>
                        <if condition="$vo.status eq 1">
                            <span class="label label-success">
                                {$status[$vo['status']]}
                            </span>
                            <else/>
                            <span class="label btn-danger">
                                {$status[$vo['status']]}
                            </span>
                        </if>
                    </td>
                    <td>
                        <a class="btn btn-xs btn-success"  href="{:url('Course/edit',array('course_id'=>$vo['course_id']))}">{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('Course/delete',array('course_id'=>$vo['course_id']))}">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>